package com.akkainaction.helloactor.circuitbreaker;

import akka.actor.ActorRef;
import akka.actor.ActorSystem;
import akka.actor.Props;
import com.akkainaction.helloactor.circuitbreaker.actor.CircuitBreakerActor;

import java.util.concurrent.TimeUnit;

public class TestCircuitBreakerActor {

    public static void main(String[] args) {
        ActorSystem system = ActorSystem.create("sys");
        ActorRef circuitBreakerActor = system.actorOf(Props.create(CircuitBreakerActor.class), "circuitBreakerActor");
        circuitBreakerActor.tell("sync1",ActorRef.noSender());
        circuitBreakerActor.tell("sync2",ActorRef.noSender());
        circuitBreakerActor.tell("sync3",ActorRef.noSender());
        circuitBreakerActor.tell("sync4",ActorRef.noSender());
        circuitBreakerActor.tell("sync5",ActorRef.noSender());
        circuitBreakerActor.tell("sync6",ActorRef.noSender());
        circuitBreakerActor.tell("sync7",ActorRef.noSender());
        circuitBreakerActor.tell("sync8",ActorRef.noSender());
        circuitBreakerActor.tell("sync9",ActorRef.noSender());
        circuitBreakerActor.tell("sync10",ActorRef.noSender());
        try {
            System.out.println("----睡眠2分钟-----");
            TimeUnit.MINUTES.sleep(2);
            System.out.println("----继续执行-----");
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        circuitBreakerActor.tell("sync11",ActorRef.noSender());
        circuitBreakerActor.tell("sync12",ActorRef.noSender());
        circuitBreakerActor.tell("sync13",ActorRef.noSender());
        circuitBreakerActor.tell("sync14",ActorRef.noSender());
        circuitBreakerActor.tell("sync15",ActorRef.noSender());
        circuitBreakerActor.tell("sync16",ActorRef.noSender());
    }
}
